package com.woniuxy.java102vuecli.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author author
 * @Create 2023-09-27 15:41
 */
@RestController
public class EmailController {
    @Autowired
    RabbitTemplate rabbitTemplate;
    @RequestMapping("/email/{email}")
    public ResponseResult email(@PathVariable("email") String email){
        //多线程优化
//        new Thread(() -> MailUtil.send("chinasofti_lbs@163.com", "102测试", "邮件来自Hutool测试", false)).start();
        //使用消息队列解耦，提高性能
        rabbitTemplate.convertSendAndReceive("exchangetopic", "email", email);
        return new ResponseResult(200,"ok","email发送成功，请查收");
    }
}
